Not able to detect current open out-link module

Hi,

I'm opening a module from DXL and then following out-link and passing through a couple of sub-modules. The problem I'm having is when I look at the current module I'm still seeing the original module I opened.

Can anyone offer any assistance to help me workout how to get the current module when looking at an opened link module.

Cheers
S
StuartRobin - Fri Dec 03 03:50:52 EST 2010

Re: Not able to detect current open out-link module
Tony_Goodman - Fri Dec 03 03:58:35 EST 2010

Generally, when you open a module, it becomes the "current Module", but modules at the other end of outgoing linsk are opened automatically by DOORS, so following links and opening them may not necessarily update the "current Module".

Beware of relying on the current Module being set. You should set it explicitly as follows:

// get a handle on the module
m = read("/project name/module name", true)

// force current Module setting (there two under scores in ModuleRef__)
(current ModuleRef__) = m
Tony

Re: Not able to detect current open out-link module
StuartRobin - Fri Dec 03 04:10:37 EST 2010

Thank you for your help but I've already done that. The problem is that I can't predict the final module that will be selected.

Re: Not able to detect current open out-link module
llandale - Fri Dec 03 14:16:33 EST 2010

Welcome back Tony.

As for 'current' module: This notion is useful for scripts that must have a module for their context; that is the script runs on a module. All such scripts should have something like this at the top:

Module g_modOriginal = current()
if (null g_modOriginal    or
    type(g_modOrginal != "Formal") {errorBox("Run from open formal module"); halt}
// some other possibilities
if (!isEdit(g_modOriginal)   or
    !isShare(g_modOriginal))   {errorBox("run from Share/Edit module"); halt}


This way you always have a handle on the original module when you need it, which you will when you open other modules. If you figure to use commands that require the 'current' module, you can issue: current = g_modOriginal.

When you open other modules, the 'current' module can and does change. I don't know the exact rules but I see the rules vary from DOORS version to version. The main rule, which I believe is about 90% accurate, is that the 'current' module changes when you actually open another module, but it does not change if that other module is already open. BUT WAIT! it does if the module was invisible but is now visible. BUT WAIT! it does not if that module was already the the target of an open link module. BUT WAIT! it does if you loaded the link set. BUT WAIT! It does if you close the current current module, and then re-open some already open module. BUT WAIT! It doesn't change if you close that module and then immediately re-open it, before the background client-to-server chatter has had a chance to update your client with the fact that its closed. BUT WAIT! I've made up most of these 'but waits', or maybe I'm fibbing about that. Can you tell the difference? BUT WAIT ...

Attempting to find all the rules for when the 'current' module changes is hopeless, as is trying to code to such rules. Been there, done that, wasted a good week of work, never figured it out EXACTLY.

Forget relying on "mod = current" to get what you want inside some code, other than at the top as explained above. Instead, keep track of your various 'Module' handles and use them explicitely; current = modThatIJustIponed. Understand you can always get the 'Module' handle by re-issueing a 'read' command on a full name that's already open; and in some other ways.

===As for this problem====, it seems as though you are recursively opening modules at the other end of outgoing links, will accumulate several such modules, then figure out which one is the 'key' you care about, and then you need to deal with that module. Well, open your modules and keep track of their names; when you figure out which one you care about then re-open that one to get its 'Module' handle, then use that.

 

 

  • Louie